
. $psScriptRoot\Set-Sql.ps1
$Script:RSDDSql = @{}
get-childitem $psScriptRoot\sql | where {$_.PSIsContainer} | foreach {$Script:RSDDSql.$($_.Name) = @{}}
get-childitem $psScriptRoot\sql -Recurse -Include *.sql | foreach {Set-Sql -dbms $([System.IO.Path]::GetFileName("$($_.Directory)")) -key $_.BaseName -path $_.FullName }
[xml]$config = Get-Content $psScriptRoot\RSDD.psm1.config
$Script:OleDbConnString = select-xml -Xml $config -xpath "configuration/connectionStrings/add" | Select -Expand Node | where {$_.name -eq "RSDD.Oledb"} | Select -Expand connectionString
$Script:SqlClientConnString = select-xml -Xml $config -xpath "configuration/connectionStrings/add" | Select -Expand Node | where {$_.name -eq "RSDD.SqlClient"} | Select -Expand connectionString
$Script:MaxRunspaces = select-xml -Xml $config -xpath "configuration/appSettings/add" | Select -Expand Node | where {$_.key -eq "MaxRunspaces"} | Select -Expand value

. $psScriptRoot\Get-OLEDBData.ps1
. $psScriptRoot\Write-DataTable.ps1
. $psScriptRoot\Write-LogMessage.ps1
. $psScriptRoot\Get-Columns.ps1
. $psScriptRoot\Get-KeyColumnUsage.ps1
. $psScriptRoot\Get-ReferentialConstraints.ps1
. $psScriptRoot\Get-TableConstraints.ps1
. $psScriptRoot\Import-RSDD.ps1
. $psScriptRoot\Add-Dbms.ps1

#These functions and variables are not needed by threads when running multithreaded. Bypass loading them by specifying -ArgumentList:
#Import-Module RSDD -ArgumentList 1
if ( $Args.Length -eq 0 ) {
    . $psScriptRoot\Library-StringCrypto.ps1
    . $psScriptRoot\Get-Exclusion.ps1
    . $psScriptRoot\Get-ConnectionString.ps1
    $Script:Password = select-xml -Xml $config -xpath "configuration/appSettings/add" | Select -Expand Node | where {$_.key -eq "Password"} | Select -Expand value
    $Script:Exclusion = Get-Exclusion
}

Export-ModuleMember -function * -variable MaxRunspaces
